package com_djm_2025_06_05;
/**
 * 演示构造方法的重载和在一个构造方法中调用其他的构造方法
 *
 * @authour dengjiangming
 * @date 2025-06-06
 * @version 1.0.0
 */

import java.util.Objects;


public class Student {
    private String name;

    private int age;

    public String id;

    private double averageGrade;

    public String className;

    public Student() {
    }

    public Student(String name, int age, String id, double averageGrade, String className) {
        this(name, age, id, averageGrade);
        this.className = className;
    }

    public Student(String name, int age, String id) {
        this.name = name;
        this.age = age;
        this.id = id;
    }

    public Student(String name, int age, String id, double averageGrade) {
        this(name, age, id);
        this.averageGrade = averageGrade;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getAverageGrade() {
        return averageGrade;
    }

    public void setAverageGrade(double averageGrade) {
        this.averageGrade = averageGrade;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", id='" + id + '\'' +
                ", averageGrade=" + averageGrade +
                ", className='" + className + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Double.compare(student.averageGrade, averageGrade) == 0 && Objects.equals(name, student.name) && Objects.equals(id, student.id) && Objects.equals(className, student.className);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, id, averageGrade, className);
    }

    public static void main(String[] args) {
        Student stu = new Student("dengjiangming", 22, "007", 3.6,"Java");

        System.out.println(stu);
    }
}
